package com.yonyou.pmclouds.constructionlog.mapper;

import com.yonyou.pmclouds.basecom.cache.RedisCache;
import com.yonyou.pmclouds.basecom.dao.BaseMapper;
import com.yonyou.pmclouds.constructionlog.entity.ConstructionLogListViewVO;
import com.yonyou.pmclouds.constructionlog.entity.ConstructionLogRefVO;
import com.yonyou.pmclouds.constructionlog.entity.ConstructionLogVO;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@CacheNamespace(implementation = RedisCache.class)
public interface ConstructionLogMapper extends BaseMapper<ConstructionLogVO>{

    @Select("select * from pm_constructionlog where   pk_project = #{pk_project} and dr = 0  order by creationtime desc")
    @ResultMap("getMap")
    ConstructionLogVO[] selectByPkProject(String pk_project);
    @Select("select * from pm_constructionlog where   pk_project = #{pk_project} and dr = 0  order by creationtime desc")
    @ResultMap("viewMap")
    ConstructionLogListViewVO[] selectLists(String pk_project);

    @Select("select * from pm_constructionlog where   pk_constructionlog in (${strIds}) and dr = 0  order by creationtime desc")
    @ResultMap("viewMap")
    ConstructionLogListViewVO[] getViewVOByIds(@Param("strIds") String strIds);
    
    Integer selectRefByCode(@Param("code")String code,@Param("ids") String[] ids);

    @Select("select * from pm_constructionlog where   pk_project = #{pk_project} and dr = 0 and billstatus = 9 order by creationtime desc")
    @ResultMap("refMap")
    ConstructionLogRefVO[] selectRefVOByProject(String pk_project);

    ConstructionLogRefVO[] selectRefByIds(@Param("ids") String[] ids);

    List<ConstructionLogVO> queryVosByParams(@Param("params") Map<String, Object> params);

    ConstructionLogVO[] queryByCondition(@Param("pkProjects")String[] pkProjects,
                                        @Param("creators") String[] creators,
                                        @Param("startDate") String startDate,
                                        @Param("endDate") String endDate,
                                        @Param("billStatus") int[] billStatus,
                                        @Param("start") int start,
                                        @Param("size") int size);
    int countByCondition(@Param("pkProjects")String[] pkProjects,
                         @Param("creators") String[] creators,
                         @Param("startDate") String startDate,
                         @Param("endDate") String endDate,
                         @Param("billStatus") int[] billStatus);

    ConstructionLogVO[] queryAllProjectParts();

    void updatePkProjectParts(@Param("pkProject") String pkProject, @Param("partName") String partName, @Param("pkProjectpart") String pkProjectpart);
}
